package com.kj.xuyuan.adapter;

import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kj.xuyuan.R;
import com.kj.xuyuan.http.UrlConstants;
import com.kj.xuyuan.model.DynamicDetailsBean;
import com.kj.xuyuan.util.GlideUtils;

import java.util.List;

import androidx.annotation.Nullable;

public class DynamicCommentAdapter extends BaseQuickAdapter<DynamicDetailsBean.CommentListBean, BaseViewHolder> {

    public DynamicCommentAdapter() {
        super(R.layout.item_dynamic_comment);
    }

    @Override
    protected void convert(BaseViewHolder helper, DynamicDetailsBean.CommentListBean item) {
        ImageView ivHead = helper.getView(R.id.iv_head);
        GlideUtils.loadCircleImage(mContext, UrlConstants.Base_Http+item.getUser().getAvatar(),ivHead);
        helper.setText(R.id.tv_name,item.getUser().getNickname()+" "+item.getCreatetime());
        helper.setText(R.id.tv_content,item.getContent());

        TextView tvSex = helper.getView(R.id.tv_sex);

        tvSex.setText(item.getUser().getYears());
        Drawable sexDrawable = null;
        if(item.getUser().getGender().equals("1")){//1男2女
            tvSex.setBackgroundResource(R.drawable.shape_blue_20);
            sexDrawable = mContext.getResources().getDrawable(R.mipmap.icon_boy);
        }else{
            tvSex.setBackgroundResource(R.drawable.shape_pink_corners_30);
            sexDrawable = mContext.getResources().getDrawable(R.mipmap.icon_girl);
        }
        sexDrawable.setBounds(0,0,sexDrawable.getMinimumWidth(),sexDrawable.getMinimumHeight());
        tvSex.setCompoundDrawables(sexDrawable,null,null,null);
    }
}
